home *** CD-ROM | disk | FTP | other *** search
/ Aminet 45 / Aminet 45 (2001)(GTI - Schatztruhe)[!][Oct 2001].iso / Aminet / gfx / x11 / x3270_3_2_16.lha / amiga_src / 3270ds.h next >
Text File  |  2008-12-15  |  10KB  |  299 lines

  1. /*
  2.  * Modifications Copyright 1993, 1994, 1995, 1999, 2000 by Paul Mattes.
  3.  * Original X11 Port Copyright 1990 by Jeff Sparkes.
  4.  *  Permission to use, copy, modify, and distribute this software and its
  5.  *  documentation for any purpose and without fee is hereby granted,
  6.  *  provided that the above copyright notice appear in all copies and that
  7.  *  both that copyright notice and this permission notice appear in
  8.  *  supporting documentation.
  9.  *
  10.  * Copyright 1989 by Georgia Tech Research Corporation, Atlanta, GA 30332.
  11.  *  All Rights Reserved.  GTRC hereby grants public use of this software.
  12.  *  Derivative works based on this software must incorporate this copyright
  13.  *  notice.
  14.  */
  15.  
  16. /*
  17.  *    3270ds.h
  18.  *
  19.  *        Header file for the 3270 Data Stream Protocol.
  20.  */
  21.  
  22. /* 3270 commands */
  23. #define CMD_W        0x01    /* write */
  24. #define CMD_RB        0x02    /* read buffer */
  25. #define CMD_NOP        0x03    /* no-op */
  26. #define CMD_EW        0x05    /* erase/write */
  27. #define CMD_RM        0x06    /* read modified */
  28. #define CMD_EWA        0x0d    /* erase/write alternate */
  29. #define CMD_RMA        0x0e    /* read modified all */
  30. #define CMD_EAU        0x0f    /* erase all unprotected */
  31. #define CMD_WSF        0x11    /* write structured field */
  32.  
  33. /* SNA 3270 commands */
  34. #define SNA_CMD_RMA    0x6e    /* read modified all */
  35. #define SNA_CMD_EAU    0x6f    /* erase all unprotected */
  36. #define SNA_CMD_EWA    0x7e    /* erase/write alternate */
  37. #define SNA_CMD_W    0xf1    /* write */
  38. #define SNA_CMD_RB    0xf2    /* read buffer */
  39. #define SNA_CMD_WSF    0xf3    /* write structured field */
  40. #define SNA_CMD_EW    0xf5    /* erase/write */
  41. #define SNA_CMD_RM    0xf6    /* read modified */
  42.  
  43. /* 3270 orders */
  44. #define ORDER_PT    0x05    /* program tab */
  45. #define ORDER_GE    0x08    /* graphic escape */
  46. #define ORDER_SBA    0x11    /* set buffer address */
  47. #define ORDER_EUA    0x12    /* erase unprotected to address */
  48. #define ORDER_IC    0x13    /* insert cursor */
  49. #define ORDER_SF    0x1d    /* start field */
  50. #define ORDER_SA    0x28    /* set attribute */
  51. #define ORDER_SFE    0x29    /* start field extended */
  52. #define ORDER_YALE    0x2b    /* Yale sub command */
  53. #define ORDER_MF    0x2c    /* modify field */
  54. #define ORDER_RA    0x3c    /* repeat to address */
  55.  
  56. #define FCORDER_NULL    0x00    /* format control: null */
  57. #define FCORDER_FF    0x0c    /*           form feed */
  58. #define FCORDER_CR    0x0d    /*           carriage return */
  59. #define FCORDER_NL    0x15    /*           new line */
  60. #define FCORDER_EM    0x19    /*           end of medium */
  61. #define FCORDER_DUP    0x1c    /*           duplicate */
  62. #define FCORDER_FM    0x1e    /*           field mark */
  63. #define FCORDER_SUB    0x3f    /*           substitute */
  64. #define FCORDER_EO    0xff    /*           eight ones */
  65.  
  66. /* SCS control code, some overlap orders */
  67. #define SCS_BS          0x16    /* Back Space  */
  68. #define SCS_BEL        0x2f    /* Bell Function */
  69. #define SCS_CR          0x0d    /* Carriage Return */
  70. #define SCS_ENP        0x14    /* Enable Presentation */
  71. #define SCS_FF        0x0c    /* Forms Feed */
  72. #define SCS_GE        0x08    /* Graphic Escape */
  73. #define SCS_HT        0x05    /* Horizontal Tab */
  74. #define SCS_INP        0x24    /* Inhibit Presentation */
  75. #define SCS_IRS        0x1e    /* Interchange-Record Separator */
  76. #define SCS_LF        0x25    /* Line Feed */
  77. #define SCS_NL        0x15    /* New Line */
  78. #define SCS_SA        0x28    /* Set Attribute */
  79. #define SCS_SET        0x2b    /* Set: */
  80. #define  SCS_SHF    0xc1    /*  Horizontal format */
  81. #define  SCS_SLD    0xc6    /*  Line Density */
  82. #define  SCS_SVF    0xc2    /*  Vertical Format */
  83. #define SCS_TRN        0x35    /* Transparent */
  84. #define SCS_VCS        0x04    /* Vertical Channel Select */
  85. #define SCS_VT        0x0b    /* Vertical Tab */
  86.  
  87. /* Structured fields */
  88. #define SF_READ_PART    0x01    /* read partition */
  89. #define  SF_RP_QUERY    0x02    /*  query */
  90. #define  SF_RP_QLIST    0x03    /*  query list */
  91. #define   SF_RPQ_LIST    0x00    /*   QCODE list */
  92. #define   SF_RPQ_EQUIV    0x40    /*   equivalent+ QCODE list */
  93. #define   SF_RPQ_ALL    0x80    /*   all */
  94. #define SF_ERASE_RESET    0x03    /* erase/reset */
  95. #define  SF_ER_DEFAULT    0x00    /*  default */
  96. #define  SF_ER_ALT    0x80    /*  alternate */
  97. #define SF_SET_REPLY_MODE 0x09    /* set reply mode */
  98. #define  SF_SRM_FIELD    0x00    /*  field */
  99. #define  SF_SRM_XFIELD    0x01    /*  extended field */
  100. #define  SF_SRM_CHAR    0x02    /*  character */
  101. #define SF_CREATE_PART    0x0c    /* create partition */
  102. #define  CPFLAG_PROT    0x40    /*  protected flag */
  103. #define  CPFLAG_COPY_PS    0x20    /*  local copy to presentation space */
  104. #define  CPFLAG_BASE    0x07    /*  base character set index */
  105. #define SF_OUTBOUND_DS    0x40    /* outbound 3270 DS */
  106. #define SF_TRANSFER_DATA 0xd0   /* file transfer open request */
  107.  
  108. /* Query replies */
  109. #define QR_SUMMARY    0x80    /* summary */
  110. #define QR_USABLE_AREA    0x81    /* usable area */
  111. #define QR_ALPHA_PART    0x84    /* alphanumeric partitions */
  112. #define QR_CHARSETS    0x85    /* character sets */
  113. #define QR_COLOR    0x86    /* color */
  114. #define QR_HIGHLIGHTING    0x87    /* highlighting */
  115. #define QR_REPLY_MODES    0x88    /* reply modes */
  116. #define QR_PC3270    0x93    /* PC3270 */
  117. #define QR_DDM        0x95    /* distributed data management */
  118. #define QR_IMP_PART    0xa6    /* implicit partition */
  119. #define QR_NULL        0xff    /* null */
  120.  
  121. #define BA_TO_ROW(ba)        ((ba) / COLS)
  122. #define BA_TO_COL(ba)        ((ba) % COLS)
  123. #define ROWCOL_TO_BA(r,c)    (((r) * COLS) + c)
  124. #define INC_BA(ba)        { (ba) = ((ba) + 1) % (COLS * ROWS); }
  125. #define DEC_BA(ba)        { (ba) = (ba) ? (ba - 1) : ((COLS*ROWS) - 1); }
  126.  
  127. /* field attribute definitions
  128.  *     The 3270 fonts are based on the 3270 character generator font found on
  129.  *    page 12-2 in the IBM 3270 Information Display System Character Set
  130.  *    Reference.  Characters 0xC0 through 0xCF and 0xE0 through 0xEF
  131.  *    (inclusive) are purposely left blank and are used to represent field
  132.  *    attributes as follows:
  133.  *
  134.  *        11x0xxxx
  135.  *          | ||||
  136.  *          | ||++--- 00 normal intensity/non-selectable
  137.  *          | ||      01 normal intensity/selectable
  138.  *          | ||      10 high intensity/selectable
  139.  *          | ||        11 zero intensity/non-selectable
  140.  *          | |+----- unprotected(0)/protected(1)
  141.  *          | +------ alphanumeric(0)/numeric(1)
  142.  *          +-------- unmodified(0)/modified(1)
  143.  */
  144. #define FA_BASE            0xc0
  145. #define FA_MASK            0xd0
  146. #define FA_MODIFY        0x20
  147. #define FA_NUMERIC        0x08
  148. #define FA_PROTECT        0x04
  149. #define FA_INTENSITY        0x03
  150.  
  151. #define FA_INT_NORM_NSEL    0x00
  152. #define FA_INT_NORM_SEL        0x01
  153. #define FA_INT_HIGH_SEL        0x02
  154. #define FA_INT_ZERO_NSEL    0x03
  155.  
  156. #define IS_FA(c)        (((c) & FA_MASK) == FA_BASE)
  157.  
  158. #define FA_IS_MODIFIED(c)    ((c) & FA_MODIFY)
  159. #define FA_IS_NUMERIC(c)    ((c) & FA_NUMERIC)
  160. #define FA_IS_PROTECTED(c)    ((c) & FA_PROTECT)
  161. #define FA_IS_SKIP(c)        (FA_IS_NUMERIC(c) && FA_IS_PROTECTED(c))
  162.  
  163. #define FA_IS_ZERO(c)                    \
  164.     (((c) & FA_INTENSITY) == FA_INT_ZERO_NSEL)
  165. #define FA_IS_HIGH(c)                    \
  166.     (((c) & FA_INTENSITY) == FA_INT_HIGH_SEL)
  167. #define FA_IS_NORMAL(c)                    \
  168.     (                            \
  169.     ((c) & FA_INTENSITY) == FA_INT_NORM_NSEL    \
  170.     ||                        \
  171.     ((c) & FA_INTENSITY) == FA_INT_NORM_SEL        \
  172.     )
  173. #define FA_IS_SELECTABLE(c)                \
  174.     (                            \
  175.     ((c) & FA_INTENSITY) == FA_INT_NORM_SEL        \
  176.     ||                        \
  177.     ((c) & FA_INTENSITY) == FA_INT_HIGH_SEL        \
  178.     )
  179. #define FA_IS_INTENSE(c)                \
  180.     ((c & FA_INT_HIGH_SEL) == FA_INT_HIGH_SEL)
  181.  
  182. /* Extended attributes */
  183. #define XA_ALL        0x00
  184. #define XA_3270        0xc0
  185. #define XA_VALIDATION    0xc1
  186. #define  XAV_FILL    0x04
  187. #define  XAV_ENTRY    0x02
  188. #define  XAV_TRIGGER    0x01
  189. #define XA_OUTLINING    0xc2
  190. #define  XAO_UNDERLINE    0x01
  191. #define  XAO_RIGHT    0x02
  192. #define  XAO_OVERLINE    0x04
  193. #define  XAO_LEFT    0x08
  194. #define XA_HIGHLIGHTING    0x41
  195. #define  XAH_DEFAULT    0x00
  196. #define  XAH_NORMAL    0xf0
  197. #define  XAH_BLINK    0xf1
  198. #define  XAH_REVERSE    0xf2
  199. #define  XAH_UNDERSCORE    0xf4
  200. #define  XAH_INTENSIFY    0xf8
  201. #define XA_FOREGROUND    0x42
  202. #define  XAC_DEFAULT    0x00
  203. #define XA_CHARSET    0x43
  204. #define XA_BACKGROUND    0x45
  205. #define XA_TRANSPARENCY    0x46
  206. #define  XAT_DEFAULT    0x00
  207. #define  XAT_OR        0xf0
  208. #define  XAT_XOR    0xf1
  209. #define  XAT_OPAQUE    0xff
  210.  
  211. /* WCC definitions */
  212. #define WCC_RESET(c)        ((c) & 0x40)
  213. #define WCC_START_PRINTER(c)    ((c) & 0x08)
  214. #define WCC_SOUND_ALARM(c)    ((c) & 0x04)
  215. #define WCC_KEYBOARD_RESTORE(c)    ((c) & 0x02)
  216. #define WCC_RESET_MDT(c)    ((c) & 0x01)
  217.  
  218. /* AIDs */
  219. #define AID_NO        0x60    /* no AID generated */
  220. #define AID_QREPLY    0x61
  221. #define AID_ENTER    0x7d
  222. #define AID_PF1        0xf1
  223. #define AID_PF2        0xf2
  224. #define AID_PF3        0xf3
  225. #define AID_PF4        0xf4
  226. #define AID_PF5        0xf5
  227. #define AID_PF6        0xf6
  228. #define AID_PF7        0xf7
  229. #define AID_PF8        0xf8
  230. #define AID_PF9        0xf9
  231. #define AID_PF10    0x7a
  232. #define AID_PF11    0x7b
  233. #define AID_PF12    0x7c
  234. #define AID_PF13    0xc1
  235. #define AID_PF14    0xc2
  236. #define AID_PF15    0xc3
  237. #define AID_PF16    0xc4
  238. #define AID_PF17    0xc5
  239. #define AID_PF18    0xc6
  240. #define AID_PF19    0xc7
  241. #define AID_PF20    0xc8
  242. #define AID_PF21    0xc9
  243. #define AID_PF22    0x4a
  244. #define AID_PF23    0x4b
  245. #define AID_PF24    0x4c
  246. #define AID_OICR    0xe6
  247. #define AID_MSR_MHS    0xe7
  248. #define AID_SELECT    0x7e
  249. #define AID_PA1        0x6c
  250. #define AID_PA2        0x6e
  251. #define AID_PA3        0x6b
  252. #define AID_CLEAR    0x6d
  253. #define AID_SYSREQ    0xf0
  254.  
  255. #define AID_SF        0x88
  256. #define SFID_QREPLY    0x81
  257.  
  258. /* Colors */
  259. #define COLOR_NEUTRAL_BLACK    0
  260. #define COLOR_BLUE        1
  261. #define COLOR_RED        2
  262. #define COLOR_PINK        3
  263. #define COLOR_GREEN        4
  264. #define COLOR_TURQUOISE        5
  265. #define COLOR_YELLOW        6
  266. #define COLOR_NEUTRAL_WHITE    7
  267. #define COLOR_BLACK        8
  268. #define COLOR_DEEP_BLUE        9
  269. #define COLOR_ORANGE        10
  270. #define COLOR_PURPLE        11
  271. #define COLOR_PALE_GREEN    12
  272. #define COLOR_PALE_TURQUOISE    13
  273. #define COLOR_GREY        14
  274. #define COLOR_WHITE        15
  275.  
  276. /* Data stream manipulation macros. */
  277. #define MASK32    0xff000000U
  278. #define MASK24    0x00ff0000U
  279. #define MASK16    0x0000ff00U
  280. #define MASK08    0x000000ffU
  281. #define MINUS1    0xffffffffU
  282.  
  283. #define SET16(ptr, val) { \
  284.     *((ptr)++) = ((val) & MASK16) >> 8; \
  285.     *((ptr)++) = ((val) & MASK08); \
  286. }
  287. #define GET16(val, ptr) { \
  288.     (val) = *((ptr)+1); \
  289.     (val) += *(ptr) << 8; \
  290. }
  291. #define SET32(ptr, val) { \
  292.     *((ptr)++) = ((val) & MASK32) >> 24; \
  293.     *((ptr)++) = ((val) & MASK24) >> 16; \
  294.     *((ptr)++) = ((val) & MASK16) >> 8; \
  295.     *((ptr)++) = ((val) & MASK08); \
  296. }
  297. #define HIGH8(s)        (((s) >> 8) & 0xff)
  298. #define LOW8(s)         ((s) & 0xff)
  299.